home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / MacPNG Library / macmain.c < prev    next >
Encoding:
C/C++ Source or Header  |  1995-09-05  |  1.7 KB  |  68 lines  |  [TEXT/MMCC]

  1. // A cheep file prompt for selecting PGN files.
  2. //
  3. //    History
  4. //    1995/09/05    By R. Mark Fleming <markf@post.queensu.ca>\
  5. //                Provide the basic file select to replace unix command line prompt.
  6. //
  7. #include <stdlib.h>
  8. #include <stdio.h>
  9.  
  10. #include <Files.h>
  11. #include <LowMem.h>
  12. #include <StandardFile.h>
  13. #include <Memory.h>
  14.  
  15. int _Main( int argc, char *argv[]);
  16. int main( int argc, char *argv[])
  17.  
  18. {    StandardFileReply reply;
  19.     SFTypeList typeList;
  20.     OSErr err = noErr;
  21.     FInfo        ioFlFndrInfo;
  22.     long        type, creator;
  23.     short savedVol;
  24.     char *Myargv[2];
  25.     Str255 appName;
  26.     
  27.     BlockMoveData((Ptr)LMGetCurApName(), (Ptr)appName, sizeof(Str31));    // Get the current application name
  28.     p2cstr(appName);
  29.     Myargv[0] = (char *) &appName[0];                                    // Arg[0] = application name
  30.     
  31.     fprintf(stderr, "%s\nFreeware, convert to Macintosh by Mark Fleming\n", appName);
  32.     
  33.     StandardGetFile(nil, -1,    typeList, &reply);
  34.     while (reply.sfGood && err == noErr) {
  35.             
  36.         err = FSpGetFInfo(&reply.sfFile, &ioFlFndrInfo);
  37.     
  38.         creator = ioFlFndrInfo.fdCreator;        // If need check creator or type...
  39.         type = ioFlFndrInfo.fdType;
  40.         
  41.         err = GetVol(0, &savedVol);
  42.         if (err == noErr)
  43.         {
  44.             err = HSetVol(0, reply.sfFile.vRefNum, reply.sfFile.parID);
  45.             if (err == noErr)
  46.             {
  47.                 p2cstr(reply.sfFile.name);
  48.                 Myargv[1] = (char *)reply.sfFile.name;
  49.     
  50.                 fprintf(stderr, "Processing file: %s\n", Myargv[1]);
  51.     
  52.                 _Main(2, Myargv);
  53.                 
  54.                 c2pstr((char*)reply.sfFile.name);
  55.             }
  56.             SetVol(0, savedVol);
  57.         }
  58.                 
  59.     if (err != noErr)    SysBeep(0);    /* End if Err */
  60.         
  61.     StandardGetFile(nil, -1,    typeList, &reply);
  62.     }    // End while()
  63.     
  64.     fprintf(stderr, "\nSelect Quit from File menu to exit %s.\n", Myargv[0]);
  65.     
  66.     return err;
  67. }    /* End of () */
  68.